package com.jsoft.service;

import com.jsoft.dto.ProductDto;
import com.jsoft.manager.ProductManager;
import com.jsoft.model.ProductDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * Date: 04.09.13
 * Time: 23:19
 */

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductManager productManager;

    @Override
    @Transactional(readOnly = true)
    public List<ProductDto> getList() {
        List<ProductDao> productDaoList = productManager.getAllList();
        List<ProductDto> productDtoList = new ArrayList<ProductDto>();
        for (ProductDao dao : productDaoList) {
            productDtoList.add(dao.wrapProductDto());
        }
        return productDtoList;
    }
}
